package com.android.replace;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;

public class Translation {
	
	public static void translateName(String file){
		if(TextUtils.isEmpty(file)){
			return;
		}
		HashMap<String,String > stringMap = new HashMap<String, String>();
		File sourceFile = new File(file);
		BufferedReader br;
		try {
			br = new BufferedReader(new FileReader(sourceFile));
			String line;
			while ((line = br.readLine())!=null) {
				if(TextUtils.isEmpty(line)||stringMap.containsKey(line)){
					continue;
				}
				stringMap.put(line, line);
				String target = line.replaceAll(" ", "_");
				String upperCase = target.toUpperCase();
				System.out.println("public static final String TRID_"+upperCase+" = "+"\""+line+"\";");
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
		translateName("C:\\Users\\yl1132\\Desktop\\translate.txt");
	}

}
